package controller;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import model.EmailDAO;
import model.Model;
import model.UserDAO;

import databean.Email;
import databean.User;


public class ConversationMapAction extends Action {

	private UserDAO		userDAO;
	private EmailDAO	emailDAO;

	public ConversationMapAction(Model model) {
		userDAO  = model.getUserDAO();
		emailDAO = model.getEmailDAO();
	}

	public String getName() { return "conversation-map.do"; }

	public String perform(HttpServletRequest request,HttpServletResponse response) {
        
		// Set up the errors list
        List<String> errors = new ArrayList<String>();
        request.setAttribute("errors",errors);
        
        HttpSession session = request.getSession();
        
		try {
	        
			if (session.getAttribute("user") == null) {
				return "user-login.do";
			}
	        
			request.setAttribute("user",(User) request.getSession(false).getAttribute("user"));

	        return "conversation-map.jsp";	        
	        
        } catch (Exception e) {
        	errors.add(e.getMessage());
        	return "user-error-list.jsp";
        }
        
    }
}

